<template>
  <work-template v-model="detailForm" @submitOn="submitOn" @closeSelectedTag="closeSelectedTag" :butShow="isEdit">
    <div slot="form">
      <new-indicator v-model="detailForm" ref="refNewIndicator" :state="isEdit"/>
      <!--      <index-feedback  v-model="detailForm" />-->
    </div>
  </work-template>
</template>

<script>
import {
  getToken
} from "@/utils/auth";
import {
  addCarIndex
} from "@/api/IndexManagement/IndexManagement.js";
import CitySelect from "../../components/citySelect.vue"

export default {
  dicts: ['work_order_type', 'online_offline'],
  name: "IndexManagementApply",
  components: {
    CitySelect,
    newIndicator: () => import('../components/newIndicator.vue'),
    indexFeedback: () => import('../components/indexFeedback.vue')
  },

  data() {
    return {
      citySelection: [],
      isNewEnergy: false,
      isFuel: false,
      rules: {
        applyTime: [
          {required: true, message: '请选择申请时间', trigger: 'change'}
        ],
        cityName: [
          {required: true, message: '请输入申请城市', trigger: 'blur'},
        ],
        indicatorType: [
          {required: true, message: '请选择指标类型', trigger: 'change'}
        ],
        fuelNum: [
          {required: true, message: '请输入燃油指标数量', trigger: 'blur'}
        ],
        newEnergyNum: [
          {required: true, message: '请输入新能源指标数量', trigger: 'blur'}
        ],
        newEnergyEarnestMoney: [
          {required: true, message: '请输入申请保证金合计金额', trigger: 'blur'}
        ],
        newEnergyAuctionMoney: [
          {required: true, message: '请输入竞拍合计金额', trigger: 'blur'}
        ],
        fuelMethod: [
          {required: true, message: '请选择燃油指标申请方式', trigger: 'change'}
        ],
        newEnergyMethod: [
          {required: true, message: '请选择新能源指标申请方式', trigger: 'change'}
        ],

        // indexVoucher: [
        //   { required: true, message: '请选择指标凭证', trigger: 'change' }
        // ],
        reason: [
          {required: true, message: '请输入申请原因', trigger: 'blur'}
        ]
      },

      isForm: true,
      // 表单参数
      detailForm: {
        citySelection: [],
        cityId: "",
        indicatorType: [],
        applyTime: "",
        cityName: "",
        fuelNum: "",
        fuelMethod: "",
        newEnergyNum: "",
        newEnergyMethod: "",
        newEnergyEarnestMoney: "",
        newEnergyAuctionMoney: "",
        reason: "",
        indexVoucher: ""
      },

    };
  },
  watch: {},
  computed: {
    isShow() {

      return true

    },
    isEdit() {
      let a = 'write'
      return a

    },


  },
  created() {

  },
  mounted() {

  },
  methods: {

    closeSelectedTag(view) {
      this.$tab.closePage(view).then(({visitedViews}) => {
        this.$router.push({
          path: "/pzzx/IndexManagementList",
        })
      })
    },

    // 提交操作
    submitOn() {
      this.$refs.refNewIndicator.handleEffect().then(() => {
        const loading = this.$loading({
          lock: true,
          text: '保存中',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        addCarIndex(this.detailForm).then((res) => {
          if (res.code === 200) {
            loading.close();
            this.closeSelectedTag()
          }
        }).catch(() => {
          loading.close();
        })
      }).catch(() => {
      })

    },

  }
};
</script>


<style lang="scss" scoped>
.box-card {
  font-size: 14px;
  margin-bottom: 16px;

  ::v-deep .el-card__header {
    padding: 0;
    height: 48px;
    margin: 0 14px;
    display: flex;
    align-items: center;

    .header-card {
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex: 1;

      .header-card-title {
        font-size: 16px;
        color: #333333;
        font-family: PingFangSC, PingFang SC;
        font-weight: 500;
      }
    }
  }

  ::v-deep .el-card__body {
    padding: 10px 14px;

  }

  .box-card-inp {
    display: flex;
    align-items: center;
    margin-bottom: 20px;

    .inp-name {
      width: 130px;
      text-align: right;
      font-size: 14px;
    }

    .inp-name-r {
      flex: 1;
    }
  }

  .top-card {
    display: flex;

    .top-card-right {
      flex: 1;
      font-size: 14px;
      line-height: 36px;
      margin-left: 20px;
    }
  }
}

::v-deep .el-form-item__label {
  font-size: 14px;
  font-family: PingFangSC, PingFang SC;
  font-weight: 400;
  color: #464646;
}
</style>
